package com.minxi.jsp.controtroller;

import com.minxi.jsp.javabean.Userinfo;
import com.sun.deploy.net.MessageHeader;

import javax.servlet.http.HttpSession;
import java.sql.*;
import java.util.ArrayList;

public class ListServlet {
    public static <userInfo> void main(String[] args) throws Exception {
        PreparedStatement preparedStatement = null;
        Connection connection = null;
        ArrayList<Userinfo> list = new ArrayList<>();

        try{ //注册驱动
            Class.forName("com.mysql.cj.jdbc.Driver");
            //获取连接
            String url="jdbc；mysql;//127.0.0.1:3306/student?serverTimezone=Asia/Shanghai";
            String userName="root";
            String passWord="123456";
            Connection conn = DriverManager.getConnection(url,userName,passWord);
            //定义sql
            String sql ="update user_info set user_name = '刘小东' where id = 1;";
            //获取执行sql对象
            PreparedStatement PreparedStatement = conn.prepareStatement(sql);
            ResultSet resultSet =preparedStatement.executeQuery();
            while(resultSet.next()){
                Userinfo userInfo = new Userinfo();
                Userinfo.setid(resultSet.getLong("id"));
                Userinfo.setusername(resultSet.getString("user_name"));
                Userinfo.setUserAge(resultSet.getString("user_age"));
                Userinfo.setUSersex(resultSet.getString("user_sex"));
                list.add(userInfo);


            }
            HttpSession session1 =  ;

        }catch (Exception e) {
            e.printStackTrace();
        }



    }

}
